﻿using TiaoTiaoCode.Common.Enums;

namespace TiaoTiaoCode.Modbuser.Interfaces
{
    /// <summary>
    /// Modbus对象接口
    /// 底层使用FluentModbus
    /// </summary>
    public interface IModbuser
    {
        /// <summary>
        /// 站号
        /// </summary>
        byte Station { get; }

        /// <summary>
        /// 字节流顺序
        /// </summary>
        ByteDataFormatType DataFormat { get; }

        /// <summary>
        /// 首地址是否为0
        /// </summary>
        bool AddressStartWithZero { get; }

        /// <summary>
        /// 字符串是否反转
        /// </summary>
        bool IsStringReverse { get; }

        /// <summary>
        /// 检查消息是否一致
        /// </summary>
        bool CheckMessageId { get; }

        /// <summary>
        /// short ushort 是否反转
        /// </summary>
        bool IsInteger16Reverse { get; }

        /// <summary>
        /// 读
        /// </summary>
        /// <typeparam name="T">限定为基础数据类型</typeparam>
        /// <param name="addresses"></param>
        T[] Read<T>(params string[] addresses);

        /// <summary>
        /// 写
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="address"></param>
        /// <param name="value"></param>
        bool Write<T>(string address, T value);
    }
}
